package com.tz.colawallet.ui.adapter;

import android.content.Context;
import android.os.Build;
import android.support.annotation.RequiresApi;
import android.view.View;
import android.widget.TextView;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.tz.colawallet.R;
import com.tz.colawallet.bean.GetTags;

/**
 * @author tz
 * @创建日期 2017.12.11
 */

public class MainScreenAdapter extends BaseQuickAdapter<GetTags, BaseViewHolder> {
    private Context context;
    private OnListener onListener;
    private String chooseName;

    public MainScreenAdapter(int layoutResId, Context context,String chooseName) {
        super(layoutResId);
        this.context = context;
        this.chooseName = chooseName;
    }

    @RequiresApi(api = Build.VERSION_CODES.LOLLIPOP)
    @Override
    protected void convert(final BaseViewHolder helper, GetTags item) {
        TextView perText = helper.getView(R.id.item_per_text);
        perText.setText(item.getName());
        if (item.isChoose()) {
            perText.setTextColor(context.getResources().getColor(R.color.red));
//            perText.setBackgroundResource(R.drawable.shape_stroke_frame_red);
        } else {
            perText.setTextColor(context.getResources().getColor(R.color.text_color));
//            perText.setBackgroundResource(R.drawable.shape_stroke_frame_gray);
        }


        perText.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                onListener.onListener(helper.getPosition());
            }
        });
    }

    public interface OnListener {
        void onListener(int position);
    }

    public void setOnListener(OnListener onListener) {
        this.onListener = onListener;
    }
}
